<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<p id="p"></P>
		<script type="text/javascript">
			// 2. 计算现在到明年09-01的时间差, 然后开始倒计时,并输出在页面上, 输出格式: x天x小时x分钟x秒
			var preTime = new Date('2022-9-1');

			function date() {
				var newTime = new Date();
				var target = parseInt((preTime - newTime) / 1000);
				var days = Math.floor(target / (60 * 60 * 24));
				var modulo = target % (60 * 60 * 24);
				var hours = Math.floor(modulo / (60 * 60));
				var m = Math.floor(modulo / 60);
				var s = modulo % 60;

				document.getElementById("p").innerHTML = "距离2022-09-01还有:" + days + "天" + hours + "时" + m + "分" + s + "秒";
			}
			date();
			
		</script>
	</body>
</html>
